package br.org.etec.dotcao.model;

import static javax.persistence.CascadeType.MERGE;
import static javax.persistence.CascadeType.PERSIST;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

@NamedQueries(@NamedQuery(name="selectwithstate", query = "select l from City l where l.state.code = :selectcity"))
@Table(name="tcity")
@Entity
@XmlRootElement
public class City extends AbstractEntity{

	private static final long serialVersionUID = 1L;

	@Column
	private String name;

	@Column
	private String zipCode;

	@ManyToOne(cascade={PERSIST, MERGE})
	@JoinColumn(name = "state")
	private State state;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}
}
